# GMY_Replication

This directory contains replication code for "Evolution of Market Power in the US Auto Industry" by Paul Grieco, Charlie Murry, and Ali Yurukoglu

## Directory Structure

- `/data/` contains all of the source (to these programs) data (see directory README for more details).
- `/codes/` contains all Matlab and Stata scripts and functions.
- `/codes/alternative_specs/` contains scripts that estimate robustness.
- `/temp/` contains all data created by the programs (initially empty).
- `/output/tables` location of tables .tex files (initially empty).
- `/output/figures` location of figures for paper (initially empty).



## Software used for Testing

1. Matlab 2021a and 2022a
2. Stata 17 and 18 SE
   - latest ssc packages as of August 2023: ivreg2, ranktest, mat2txt  

The computer should have at least 8GB of memory. 


## Data Notes 

The MRI and Maritz data cannot be shared in their raw form. We have provided processed moments from that source data in `data`. Please contact the authors for the scripts used to prepare raw data to the form it appears in this repository.

## Code Notes


To run the code, run `main.m` in matlab from the top level directory. This does several things, but see code's inline comments for primary source of documentation: 

1. Adds the `code` directory to the path. Also attempts to compile the C or FORTRAN share inversion code, for which you need to have a compiler installed and working with matlab's `mex` utility
2. Set's up intermediate files, which are stored in the `temp` directory.    
3. Calls the main estimation function, this uses the parallel pool.
4. Perform second stage estimation using STATA.  You need an installed version of STATA (tested with versions 17 and 18) that can be run from the command line.
5. Performs the bootstrap.
6. Evaluates counterfactual analysis.
7. Saves tables and figures to the `output` directory, as well as posting figures to screen and tables to standard out.   

This code is slightly altered so that it can be run immediately on a desktop computer in a few hours to do a full run, `numIters` should be set to 200 and `nBoot` should be set to 500, see lines 15-25 of `main.m`

To clean out the logs, `temp` and `output` directory after a full or partial run, you can use the script `cleanDir.sh`, which simply deletes the generated data.

## Contact

Please direct any comments or questions to
- Paul Grieco | paul.grieco@psu.edu
- Charlie Murry | charles.murry@bc.edu
- Ali Yurukoglu | ayurukog@stanford.edu



